$(document).ready(function(){

	//登录框
	$("a[name=loginviewbtn]").toggle(
		function () { $("#UesrLogin").show();},
		function () { $("#UesrLogin").hide();}
	);


	//条目交替背景颜色
	$(".interlace tr:even").addClass("b");
	$(".interlace li:even").addClass("b");


	//按钮加强
	$("input[type=submit]").addClass("isbuttton")

	$("input[type=text] , input[type=password]").addClass("isinputbox")
	$(":input").focus( function() {
		$("input[type=text] , input[type=password]").addClass("isinputbox")
	}); 

	//表单焦点变色
	$("input , textarea , select").focus( function () { $(this).addClass("isfocus"); });
	$("input , textarea , select").blur( function () { $(this).removeClass("isfocus"); }); 

	//列表焦点行醒目
	$(".hasfocus tr:not(.spaceline)").hover(function () {
		$("td",this).addClass("ishover");},function () {$("td",this).removeClass("ishover");
	});

	//物品Armory 原型
	for (i = 0; i < $("*[name=item]").length; i ++)
	{
		var obj = $("*[name=item]:eq("+i+")"); 
		//读Armory图标
		$.get("GetArmory.asp", { mode:"2" ,itemID: obj.attr("itemID") },  
			function (data) {
				itemXml = $("<xml>" + data + "</xml>");
				if ($("icon",itemXml).text() != "") {
				$("img[itemID="+$("id",itemXml).text()+"]").attr("src","http://cn.wowarmory.com/images/icons/43x43/" + $("icon",itemXml).text() + ".png"); 
				//$("img[itemID="+$("id",itemXml).text()+"]").attr("src","http://tw.wowarmory.com/wow-icons/_images/43x43/" + $("icon",itemXml).text() + ".png"); //臺服圖標地址
				};
				//$("textarea.hi").append("http://cn.wowarmory.com/images/icons/43x43/" + $("icon",itemXml).text() + ".png");
			}
		);

		//读多玩数据库物品信息, IE不能识别为XML,暂作字符串处理
		$.get("GetArmory.asp", { mode:"3" ,itemID: obj.attr("itemID") },  
			function (data) {
				//itemTipXml = $("<xml>" + data + "</xml>");
				var itemData = data.split("#");
				if (itemData[1]) {
				$("img[itemID="+ itemData[0] +"]").attr("alt",itemData[1]);  
				};
			}
		);

	}


	//活动时间线事件描绘层级提高
	$(".timeline img.eventico").css({"position":"absolute","z-index":"7"});

	//帮助解释
	$(":input").focus(
		function () {
			var objInput = this;
			var strInputName = objInput.name;
			$.get("xml/tips.xml",
				function (data) {
					if ($("tip[name="+strInputName+"]",data).attr("text")) {
						$(objInput).after("<div class='tipbox'><img src='images/bg_tip.gif' class='array' />"+ $("tip[name="+strInputName+"]",data).attr("text") + "</div>");
						$(".tipbox").fadeIn("slow");
					};
				}
			);
		}
	);

	$(":input").blur(
		function () {
			$(".tipbox").fadeOut("slow");
		}
	);
	$("*.tipbox").click(
		function () {
			$(".tipbox").fadeOut("slow");
		}
	);

 
	//活动参与玩家选单,点击选中复选框
	$(".playselecttable dd").click(
		function () {
			//this.removeClass("checked");
			$(this).toggleClass("checked"); 
			if ($("input",this).attr("checked") == "") { 
				$("input",this).attr("checked","checked"); 
			} else { 
				$("input",this).attr("checked",""); 
			}
		}
	);

	//鼠标提示层,用于显示事件img.alt的详细信息
	var alttext;
	$("img").hover(
	  function () {
		alttext = this.alt;
		if (alttext != "")
		{
		$("#dypopLayer .xbody").prepend(this.alt);
		$("#dypopLayer").css("visibility","visible");
		var imgoffset = this.offset;
		$("#dypopLayer").css("left", window.event.clientX + 5 );
		$("#dypopLayer").css("top", window.event.clientY + document.documentElement.scrollTop);
		this.alt = "";
		}
	 },
	  function () {
		$("#dypopLayer .xbody").empty();
		$("#dypopLayer").css("visibility","hidden");
		this.alt = alttext;
	  }
	); 


	$(".unkilled").css("opacity","0.2");

	//删除操作确认
	$("a[name=del]").click( function() {
		if(confirm('这将删除该玩家')) {
			return true;
		}
		return false;
	});



	//载入DKP数据到成员表
	$("select[name=dkpClassSelect]").change( function () {
		var players = $("table.playerlist tr");
		$("td.dkp",players).text("/");
		if ($("select[name=dkpClassSelect]").val() != "") {
			var playername;
			var playerdkp;
			$.get("dkplist_"+$("select[name=dkpClassSelect]").val()+".xml", function (data) {
				for (i = 0 ; i <= players.length ; i ++) {
					playername = $("a[name=playername]",players[i]).text()
					playerdkp = $("dkp[name='"+ playername +"']",data).attr("dkp")
					if (playerdkp != "") {$("td.dkp",players[i]).text(playerdkp);}
				};
			}); 
		}
	});

	//
	$("a[name=expansion]").toggle(
		function () {$("tr.expansion").show();} ,
		function () {$("tr.expansion").hide();}
	);

}); 


